Type.registerNamespace('ModWatch');

ModWatch.ModAlertCheckBox = function(element)
{
    ModWatch.ModAlertCheckBox.initializeBase(this, [element]);

    this._modGroup = '';
    this._notifyModMessage = '';
    this._isSelected = false;
}

ModWatch.ModAlertCheckBox.prototype = {

	get_modGroup : function()
	{
		return this._modGroup;
	},

	set_modGroup : function(value) {
		if (!value || value == null)
			this._modGroup = '';
		else
			this._modGroup = value;
	},

	get_notifyModMessage : function()
	{
		return this._notifyModMessage;
	},

	set_notifyModMessage : function(value) {
		if (!value || value == null)
			this._notifyModMessage = '';
		else
			this._notifyModMessage = value;
	},

	initialize : function()
	{
        ModWatch.ModAlertCheckBox.callBaseMethod(this, 'initialize');

		this.get_element().selected = this._isSelected;
    },

	checkForChange : function()
	{
		var cancelChange = false;

		if (ModWatch.ModManagerInstance &&
			ModWatch.ModManagerInstance.isChangeDetected(this.get_modGroup()))
		{
			if (!confirm(this.get_notifyModMessage()))
				cancelChange = true;
		}

		if (cancelChange)
		{
			// roll back the change
			this.get_element().selected = this._isSelected;
		}
		else
		{
			// store the new selected index
			this._isSelected = this.get_element().selected;
		}
		
		return cancelChange;
	}

}

ModWatch.ModAlertCheckBox.registerClass('ModWatch.ModAlertCheckBox', Sys.UI.Control);

if (typeof(Sys) !== 'undefined')
	Sys.Application.notifyScriptLoaded();
